package com.example.backend.dto;

import com.example.backend.entity.User;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

public class UserDto {

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class CreateRequest {
        @NotBlank(message = "用户名不能为空")
        @Size(min = 3, max = 50, message = "用户名长度必须在3到50个字符之间")
        private String username;

        @NotBlank(message = "邮箱不能为空")
        @Email(message = "邮箱格式不正确")
        private String email;

        @NotBlank(message = "密码不能为空")
        @Size(min = 6, message = "密码长度至少为6个字符")
        private String password;

        private String nickname;
        private String bio;
        private String avatarUrl;
    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class UpdateRequest {
        @Email(message = "邮箱格式不正确")
        private String email;

        @Size(min = 6, message = "密码长度至少为6个字符")
        private String password;

        @Size(max = 100, message = "昵称长度不能超过100个字符")
        private String nickname;

        @Size(max = 500, message = "个人简介长度不能超过500个字符")
        private String bio;

        private String avatarUrl;
    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Response {
        private Long id;
        private String username;
        private String email;
        private String nickname;
        private String bio;
        private String avatarUrl;
        private User.UserRole role;
        private User.UserStatus status;
        private LocalDateTime createdAt;
        private LocalDateTime updatedAt;
    }
}
